﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.OfficeArt
{
    internal class OfficeArtBlipPICT : OfficeArtHeaderedBlip //\\with metafile
    {
        private PictFormat _nativeFormat;

        public OfficeArtBlipPICT(byte[] data)
            : base(data)
        {
            NativeFormat = PictFormat.One;
        }

        public OfficeArtBlipPICT()
            : base()
        {
        }

        public override RecType RecordType
        {
            get { return RecType.OfficeArtBlipPICT; }
        }


        protected override string Extension
        {
            get { return "pict"; }
        }

        protected override ushort Format
        {
            get { return (ushort)NativeFormat; }
            set { NativeFormat = (PictFormat)value; }
        }

        private PictFormat NativeFormat
        {
            get
            {
                Contract.Ensures(Enum.IsDefined(typeof(PictFormat), Contract.Result<PictFormat>()));

                return
                    _nativeFormat;
            }
            set
            {
                Contract.Requires(Enum.IsDefined(typeof(PictFormat), value));

                _nativeFormat = value;
            }
        }

        private enum PictFormat
        {
            One = 0x542,
            Two = 0x543
        }
        protected override UidCount HasTwoIds()
        {
            switch (NativeFormat)
            {
                case PictFormat.One: return UidCount.One;
                case PictFormat.Two: return UidCount.Two;
                default:
                    throw new NotSupportedException();
            }
        }

        internal override MSOBLIPTYPE Type
        {
            get { return MSOBLIPTYPE.msoblipPICT; }
        }
    }
}